// code
export function getDayTime(time, status) {
  time = time + ''
  if (time.length !== 10) {
    return '--'
  } else {
    if (status) {
      return getTimehms(time)
    } else {
      return getTime(time)
    }
  }
}

// 获取时间
function getTime(time) {
  const date = new Date(parseInt(time) * 1000)
  const Y = date.getFullYear() + '-'
  const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
  const D = date.getDate() + ' '
  // const h = date.getHours()
  // const m = date.getMinutes() + ':'
  // const s = date.getSeconds()
  return Y + M + fix(D)// + fix(h, 2) + fix(m, 2) + fix(s, 2)
}
// 获取时间
function getTimehms(time) {
  const date = new Date(parseInt(time) * 1000)
  const Y = date.getFullYear() + '-'
  const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
  const D = date.getDate() + ' '
  const h = date.getHours() + ':'
  const m = date.getMinutes() + ':'
  const s = date.getSeconds()
  return Y + M + fix(D) + fix(h, 2) + fix(m, 2) + fix(s, 2)
}

// 加0
function fix(num) {
  if (parseInt(num) < 10) {
    return '0' + num
  } else {
    return num
  }
}
